#pragma once

#include <gmPCurve>
#include <gmDMatrix>

namespace GMlib 
{
	template <typename T>
	class BSpline : public PCurve<T>
	{
	public:
		BSpline( T size);
		BSpline( DVector<Vector<T, 3>> pts, int deg );
		BSpline( const BSpline<T>& copy );
		virtual ~BSpline();

		std::string getIdentity() const;
		bool isClosed() const;

	protected:
		T _size;
		DVector<Vector<T,3>> _pts;
		DVector<T> _knots;
		DMatrix<T> _bernMat;

		void calcBern(int d, T t, T delta, int idx);
		void eval(T t, int d, bool l);
		T getEndP();
		T getStartP();
		int _deg;

	private:
		T calcW(T t, int idx, int d);
	};
}

#include "BSpline.c"